package com.bmft.signIn.mail;

import com.bmft.signIn.conf.YamlBeanConf;
import com.bmft.system.pojo.Student;
import com.bmft.utils.mail.MailUtilImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;

/**
 * @Author Jarvan
 * @create 2020/9/7 18:59
 * 这个工具类用于向作者发送邮件警告
 */
@Component
public class MailWornUtil {
    @Autowired
    YamlBeanConf yamlBeanConf;
    @Autowired
    MailUtilImpl mailUtil;

    /**
     * 我们这里使用异步发送
     *
     * @param student
     */
    @Async
    public void sendWornMailToAuthor(Student student) throws MessagingException {
        mailUtil.sendAttachmentsMail(yamlBeanConf.getAuthorMail(), "【微重邮打卡】打卡" + student.getName() + "失败通知", "<h2 style='color:red'>打卡失败,个人信息如下</h2><p>" + student + "</p>", null);
    }
}
